package com.rtwo.config;

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * Created by hasee on 2017/6/9.
 */
@Configuration
public class ErrorPageConfig{

    @Bean
    public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer(){
        EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer = new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {
                configurableEmbeddedServletContainer.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN,"/403"),new ErrorPage(HttpStatus.NOT_FOUND,"/403"));
            }
        };
        return embeddedServletContainerCustomizer;
    }

}
